package com.wx.router;

import java.lang.reflect.Constructor;

import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpMessageRouterRule;
import me.chanjar.weixin.mp.api.WxMpService;

/**
 * 封装常用的微信解析方式
 *
 */
public class WxMpMessageRouterExt extends WxMpMessageRouter {

	public WxMpMessageRouterExt(WxMpService wxMpService) {
		super(wxMpService);
	}

	public WxMpMessageRouterRule rule(Class<? extends WxMpMessageRouterRule> clzz) {
		try {
			Constructor<? extends WxMpMessageRouterRule> c1 = clzz.getDeclaredConstructor(WxMpMessageRouter.class);
			c1.setAccessible(true);
			return c1.newInstance(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
